{extend name="layout" /}

{block name="breadcrumb"}
<h2>{$title}</h2>
<ol class="breadcrumb">
    <li><a href="{:url('index/index')}">首页</a></li>
    <li><a href="{:url('index')}">优惠券列表</a></li>
    <li><strong>{$title}</strong></li>
</ol>
{/block}

{block name="main"}
<div class="ibox float-e-margins">
    <div class="ibox-title">
        <h5>{$title}</h5>
    </div>
    <div class="ibox-content">
        <form method="post" class="form-horizontal" onsubmit="return toSubmit()">
            <div class="form-group">
                <label class="col-sm-2 control-label">名称</label>
                <div class="col-sm-6">
                    <input type="text" name="name" value="{$model ? $model.name : ''}" class="form-control" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">金额</label>
                <div class="col-sm-6">
                    <input type="text" name="money" id="money" value="{$model ? $model.money : ''}" class="form-control" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">有效期</label>
                <div class="col-sm-3">
                    <input type="text" value="{$model ? $model.start_time : ''}" name="start_time" class="start-time form-control" placeholder="开始时间">
                </div>
                <div class="col-sm-3">
                    <input type="text" value="{$model ? $model.end_time : ''}" name="end_time" class="end-time form-control" placeholder="结束时间">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">使用规则</label>
                <div class="col-sm-6">
                    <textarea name="rule" class="form-control" rows="5">{$model ? $model.rule : ''}</textarea>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">权重</label>
                <div class="col-sm-6">
                    <input type="text" name="sort_num" value="{$model ? $model.sort_num : 0}" class="form-control" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-6">
                    <select name="status" class="form-control" required>
                        {foreach $status as $key=>$vo }
                        {if ( $model && $model.status == $key ) }
                        <option value="{$key}" selected>{$vo}</option>
                        {else /}
                        <option value="{$key}">{$vo}</option>
                        {/if}
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    {if ( $model && $model.id > 0) }
                    <input type="hidden" name="id" value="{$model.id}">
                    {/if}
                    <button class="btn btn-primary" type="submit">提交</button>
                    <button class="btn btn-white" type="button"><a href="{:url('index')}">取消</a></button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

<!-- 加载其他js -->
{block name="jsFile"}
{load href="/static/css/plugins/datetimepicker/bootstrap-datetimepicker.min.css" /}
{load href="/static/js/plugins/datetimepicker/bootstrap-datetimepicker.min.js" /}

<script>

    
    $('.start-time').datetimepicker({
        weekStart: 1, // 一周从哪一天开始。0（星期日）到6（星期六）
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2, // 日期时间选择器打开之后首先显示的视图 0 hour 1 day 2 month 3 year 4 decade
        forceParse: 1, // 当用户在输入框中输入了不正确的日期，选择器将会尽量解析输入的值
        showMeridian: 1
    });
    $('.end-time').datetimepicker({
        weekStart: 1, // 一周从哪一天开始。0（星期日）到6（星期六）
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2, // 日期时间选择器打开之后首先显示的视图 0 hour 1 day 2 month 3 year 4 decade
        forceParse: 1, // 当用户在输入框中输入了不正确的日期，选择器将会尽量解析输入的值
        showMeridian: 1
    });
</script>
{/block}